<?php

namespace app\common\model\qa;

use app\common\library\Utils;
use think\Db;
use think\Model;

class Answers extends Model
{

    protected $name = 'parent_answers';
    // 开启自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';
    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = false;

    //时间获取器
    public function getCreatetimeAttr($value)
    {
        $time = Utils::time_format($value);
        return $time;
    }


    //问题的答案数量
    public function getUserInfoAttr($value, $data) {
        $info = Db::name('third')->where(['id'=> $data['user_id']])->field('avatar as image, nickname')->find();
        return $info;
    }
}
